import os
import pandas as pd
from pprint import pprint

class DataOperation:
    def __init__(self, file, path,sheet=1):
        if file == 'csv':
            self.data = pd.read_csv(path)
        elif file == 'excel':
            self.data = pd.read_excel(path,sheet)
        elif file == 'sql':
            self.data = pd.read_sql(path,sheet)
        else:
            print('找不到文件')

    def get_data_to_dict(self):
        return [self.data.loc[i].to_dict() for i in self.data.index.values]

    def get_data_to_list(self):
        return self.data.values.tolist()

if __name__ == '__main__':
    path = os.path.join(os.path.dirname(os.path.abspath(__file__)),'lj_data.csv' )
    data = DataOperation("csv",path)
    pprint(data.get_data_to_list())
